#include "T_SecondScn.h"
#include "T_App.h"

T_SecondScn::T_SecondScn()
{
	m_ridResult = GAF_ID_WAIT;
}

T_SecondScn::~T_SecondScn()
{
}

void T_SecondScn::OnCallEnd(GAF_CScene* pCallScene)
{
	if(pCallScene == &m_scnExit)
	{
		if(m_scnExit.GetReturn() == GAF_ID_YES)
			m_ridResult = GAF_ID_YES;
		else
			m_ridResult = GAF_ID_NO;
	}
}

bool T_SecondScn::OnInit(GAF_CBundle* pParam)
{
	m_pimgBack =GAF_CImage::Create("./res/SecondBack.png");
	AddGraphics(m_pimgBack);

	m_scnExit.Init();
	m_scnExit.SetAnchor_a(GAF_ANCHOR_VCENTER | GAF_ANCHOR_HCENTER);
	m_scnExit.SetLocation((int)GAF_pTHEWINDOW->GetSize_a().nWidth >> 1, GAF_pTHEWINDOW->GetSize_a().nHeight >> 1);

	return true;
}

bool T_SecondScn::OnStart()
{
	m_ridResult = GAF_ID_WAIT;

	return true;
}

void T_SecondScn::OnKeyUp(ULONG lCode)
{
	if(lCode == GAF_KEY_ESCAPE)
		ReturnOK();
#ifdef TEST_SceneShowCall
	else if(lCode == GAF_KEY_1)
		GAF_pTHEMYAPP->GetMainScene()->Show();
	else if(lCode == GAF_KEY_3)
		GAF_pTHEMYAPP->GetSubScene()->Call();
#endif
}

GAF_EReturnID T_SecondScn::OnExit(bool isCommand)
{
	if(m_ridResult == GAF_ID_WAIT)
	{
		m_scnExit.Call();
		return GAF_ID_WAIT;
	}
	else if(m_ridResult == GAF_ID_NO)
	{
		m_ridResult = GAF_ID_WAIT;
		return GAF_ID_NO;
	}
	else
		return GAF_ID_YES;
}
